/*
Copyright [2023] [fuwen_soft]
*/
package vip.xiaonuo.modular.xylogyauth.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.NoArgsConstructor;
import vip.xiaonuo.core.pojo.base.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import java.time.LocalDateTime;
import java.time.LocalDate;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.*;
import cn.afterturn.easypoi.excel.annotation.Excel;
import vip.xiaonuo.modular.xylogy.enums.XyLogyAuthEnum;

import static vip.xiaonuo.modular.xylogy.enums.XyLogyAuthEnum.ALL_ADMIN_PUTONG_AUTH;

/**
 * 用户与族谱得权限表
 *
 * @author yanwei
 * @date 2023-05-05 15:44:27
 */
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("xy_logy_auth")
@ApiModel("xy_logy_auth 实体")
@NoArgsConstructor
public class XyLogyAuth extends BaseEntity {

    public XyLogyAuth(XyLogyAuthEnum xyLogyAuthEnum, String userId,String phone,  String logyId, Integer disabled){
        this.userId = userId;
        this.phone = phone;
        this.perMisc = xyLogyAuthEnum.getAuthP();
        this.logyId = logyId;
        this.authName = xyLogyAuthEnum.getAuthName();
        this.disabled = disabled;
        this.reMark = "注册";
    }

    public XyLogyAuth(String authP,String authName, String userId,String phone,  String logyId, Integer disabled,String reMark){
        this.userId = userId;
        this.phone = phone;
        this.perMisc = authP;
        this.logyId = logyId;
        this.authName = authName;
        this.disabled = disabled;
        this.reMark = reMark;
    }


    /**
     * 
     */
    @ApiModelProperty("")
    @TableId(type = IdType.ASSIGN_ID)
    private String id;


    /**
     * 用户编号
     */
    @Excel(name = "用户编号")
    @ApiModelProperty("用户编号")
    private String userId;

    /**
     * 用户手机号
     */
    @Excel(name = "用户手机号")
    @ApiModelProperty("用户手机号")
    private String phone;


    /**
     * 族谱编号
     */
    @Excel(name = "族谱编号")
    @ApiModelProperty("族谱编号")
    private String logyId;


    /**
     * *,代表全部,指定家族成员;
多选，层级编号，也就是 ethnic id,所有派系下得
     */
    @Excel(name = "*,代表全部,指定家族成员多选，层级编号，也就是 ethnic id,所有派系下得")
    @ApiModelProperty("*,代表全部,指定家族成员;多选，层级编号，也就是 ethnic id,所有派系下得")
    private String perMisc;


    /**
     * 权限名称
     */
    @Excel(name = "权限名称")
    @ApiModelProperty("权限名称")
    private String authName;


    /**
     * 备注信息
     */
    @Excel(name = "备注信息")
    @ApiModelProperty("备注信息 - 直接展示即可")
    private String reMark;


    /**
     * 是否禁用,1=正常,2=禁用
     */
    @Excel(name = "是否禁用,1=正常,2=禁用")
    @ApiModelProperty("是否禁用,1=正常,2=禁用")
    private Integer disabled;


    /**
     * 备注信息
     */
    @Excel(name = "备注信息")
    @ApiModelProperty("备注信息 - 直接展示即可")
    @TableField(exist = false)
    private String auth;


    /**
     * 备注信息
     */
    @Excel(name = "备注信息")
    @ApiModelProperty("备注信息 - 直接展示即可")
    @TableField(exist = false)
    private String authNameP;

    /**
     * 用户编号
     */
    @Excel(name = "用户头像")
    @ApiModelProperty("用户头像")
    @TableField(exist = false)
    private String headImg;


    public  String getAuth(){
        return  "*".equals(this.perMisc) ? "1" : ALL_ADMIN_PUTONG_AUTH.getAuthP().equals(this.perMisc) ? "3" : "2";
    }

    public  String getAuthP(){
        return  "*".equals(this.perMisc) ? "管理员" : ALL_ADMIN_PUTONG_AUTH.getAuthP().equals(this.perMisc) ? "协作者" : "绑定人";
    }


}
